package com.nanhu.test.widget;

import com.nanhu.test.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

public class RotateTextView extends TextView{
	
	private  static  final  String  NAMESPACE = "http://www.ywlx.net/apk/res/com.nanhu.test";
	private  static  final  String  ATTR_ROTATE = "rotate";
	private  static  final  int  DEFAULTVALUE_DEGREES = 0;
	private  int  degrees ;
	
	public RotateTextView(Context context, AttributeSet attrs){
		super(context, attrs);
		
		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RotateText);
		degrees = a.getInt(R.styleable.RotateText_rotate, 0);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		Log.i("RotateTextView", getMeasuredWidth()/2 + " , " + getMeasuredHeight()/2);
		canvas.rotate(degrees,getMeasuredWidth()/2,getMeasuredHeight()/2);
		super.onDraw(canvas);
	}
}
